<?php

namespace App;

use App\Models\AdminUser;
use App\Models\Department;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class PlantSale extends Model
{
    protected $fillable = ['data_id', 'sn', 'name', 'buyer', 'contact_person', 'contact_mobile', 'sale_amount', 'sale_type', 'sale_date', 'user_id', 'department_id'];

    public function apply(): BelongsTo
    {
        return $this->belongsTo(PlantVariety::class, 'data_id');
    }

    public function department()
    {
        return $this->belongsTo(Department::class);
    }

    public function user()
    {
        return $this->belongsTo(AdminUser::class, 'user_id');
    }
}
